#define _CRT_SECURE_NO_WARNINGS 1
#include"Heap.h"
void testheap() {
	int a[] = { 4,2,8,1,5,6,9,7,3 };
	HP hp;
	HPinit(&hp);
	for (int i = 0; i < 9; i++) {
		HPpush(&hp, a[i]);
	}
	while (!HPempty(&hp)) {
		printf("%d ",HPTop(&hp));
		HPPop(&hp);
	} 
	printf("\n");
	printf("%d ",hp.data[3]);

}

void heapsort(int* a, int n) {
	;
	for (int i = 0; i < n; i++) {
		AdjustUp(a, i);
	}
	int end = n - 1;
	while (end) {
		swap(&a[0], &a[end]);
		AdjustDown(a, end,0);
		--end;
	}
}
int main() {
	int a[] = { 9,8,7,6,5,4,3,2,1 };
	//testheap();
	
	heapsort(a, sizeof(a)/sizeof(int));
	return 0;
}